//
//  TabBarController.m
//  KangarooDoctor
//
//  Created by gang on 2023/12/30.
//

#import "MyTabBarController.h"
#import "IndexController.h"
#import "MessageController.h"
#import "UcenterController.h"
#import "Masonry.h"
#import "UIColor+Hex.h"

@interface MyTabBarController ()

@end

@implementation MyTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIView *bgView = [[UIView alloc] initWithFrame:self.tabBar.bounds];
    bgView.backgroundColor = [UIColor whiteColor];
    [self.tabBar insertSubview:bgView atIndex:0];
    self.tabBar.opaque = YES;
    self.tabBar.unselectedItemTintColor = [UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1];
    self.navigationItem.backButtonTitle  = @"返回";

    IndexController * indexVC = [[IndexController alloc] init];
    UINavigationController * indexNavigationVC = [[UINavigationController alloc] initWithRootViewController:indexVC];
    indexVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"首页" image:[UIImage imageNamed:@"index_icon_tab_nor"] tag:1001];
    indexVC.tabBarItem.selectedImage = [UIImage imageNamed:@"index_icon_tab_selected"];
    
    
    MessageController * messageVC = [[MessageController alloc] init];
    UINavigationController * newsNavigationVC = [[UINavigationController alloc] initWithRootViewController:messageVC];
    messageVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"消息" image:[UIImage imageNamed:@"info_icon_bottom_bar_unselected"] tag:1002];
    messageVC.tabBarItem.selectedImage = [UIImage imageNamed:@"info_icon_bottom_bar_selected"];
    
    
    UcenterController * ucenterVC = [[UcenterController alloc] init];
    UINavigationController * ucenterNavigationVC = [[UINavigationController alloc] initWithRootViewController:ucenterVC];
    ucenterNavigationVC.navigationBar.backgroundColor = [UIColor colorWithHexString:@"#1E90EF"];
    ucenterNavigationVC.navigationBar.tintColor = [UIColor whiteColor];
    NSDictionary *dic = @{NSForegroundColorAttributeName : UIColor.whiteColor ,
                          NSFontAttributeName : [UIFont boldSystemFontOfSize:16]};
    ucenterNavigationVC.navigationBar.titleTextAttributes = dic;
    ucenterNavigationVC.navigationBar.barStyle = UIBarStyleDefault;
  
    ucenterVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"我的" image:[UIImage imageNamed:@"mine_icon_tab_nor"] tag:1003];
    ucenterVC.tabBarItem.selectedImage = [UIImage imageNamed:@"mine_icon_tab_selected"];

    
    self.viewControllers = @[indexNavigationVC, newsNavigationVC, ucenterNavigationVC];
    self.selectedViewController = indexNavigationVC;
    
    [self.view setBackgroundColor:[UIColor whiteColor]];
}

- (void)viewWillAppear:(BOOL)animated {
    [self.navigationController setNavigationBarHidden:YES animated:animated];
    [super viewWillAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated {
    [self.navigationController setNavigationBarHidden:NO animated:animated];
    [super viewWillDisappear:animated];
}

@end
